package cn.sdormitory.smartdor.dao;

import cn.sdormitory.smartdor.entity.SdAttence;
import cn.sdormitory.smartdor.entity.SdHygieneStudent;
import cn.sdormitory.smartdor.entity.SdLeave;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SdStudentHygieneDao extends BaseMapper<SdHygieneStudent> {

    /**
     * 根据卫生考核时间和学生编号查询学生卫生考核信息
     * @param checkDate
     * @param studentNo
     * @return
     */
    List<SdHygieneStudent> getStuByCheckDateAndBdormitoryId(@Param("checkDate") String checkDate, @Param("studentNo") String studentNo) ;

    /**
     * 根据学号修改学生卫生考核信息
     * @param studentNo
     * @param grade
     * @return
     */
    int updateStudentHygiene(@Param("studentNo") String studentNo,@Param("checkDate") String checkDate,@Param("grade") String grade);

    @Select("SELECT count(*) FROM `sd_hygiene_student` WHERE grade ='1' AND student_no = #{studentNo} ")
    Integer findStuHygieneExcellentCount(@Param("studentNo")String studentNo);

    @Select("SELECT count(*) FROM `sd_hygiene_student` WHERE grade ='2' AND student_no = #{studentNo} ")
    Integer findStuHygieneGoodCount(@Param("studentNo")String studentNo);

    @Select("SELECT count(*) FROM `sd_hygiene_student` WHERE grade ='3' AND student_no = #{studentNo} ")
    Integer findStuHygieneBadCount(@Param("studentNo")String studentNo);

    List<SdHygieneStudent> findStuBadHygieneList(@Param("studentNo")String studentNo);
}
